package logic

import (
	"context"
	"video-hubs/model/mysql"

	"video-hubs/videorpc/internal/svc"
	"video-hubs/videorpc/videorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShouAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShouAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShouAddLogic {
	return &ShouAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShouAddLogic) ShouAdd(in *videorpc.ShouAddRequest) (*videorpc.ShouAddResponse, error) {
	// todo: add your logic here and delete this line
	data := &mysql.Shou{
		UserId: int(in.UserId),
		SangId: int(in.SangId),
	}
	if err := data.ShouAdd(mysql.DB); err != nil {
		return nil, err
	}
	return &videorpc.ShouAddResponse{
		ShouId: int64(data.ID),
	}, nil
}
